package com.gjh.study.mybatis.mapper2;

import com.gjh.study.mybatis.domain.Clazz;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

/**
 * @author guangjh
 * @version 1.0
 * @date 2020/7/11 21:11
 */
public interface ClazzMapper {
    @Select("select * from tb_clazz where id = #{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "code", column = "code"),
            @Result(property = "students", column = "id",
                    many = @Many(select = "com.gjh.study.mybatis.mapper2.StudentMapper.selectStudentsByClazzId",
                    fetchType = FetchType.LAZY)),
    })
    Clazz selectClazzById(Integer id);
}
